/*************************************************************************
	> File Name: 5-1.c
	> Author: Angel Criss
	> Mail: abbytsing@gmail.com 
	> Created Time: Sat 15 Mar 2014 04:21:56 PM CST
 ************************************************************************/
//#define _FILE_OFFSET_BITS 64 /* use this macro or compile with -D_FILE_OFFSET_BITS=64

#include "ch-5.h"

int main(int argc, char *argv[])
{
    int fd;
    off_t off;
    fd=open(argv[1],O_RDWR|O_CREAT,00644);
    if(fd==-1)
        perror("cannot open/creat large file");

    off=atoll(argv[2]);//convert the initial protion of the string pointed to int
    printf("the offset is:\t%lld\n\n",off);
    sleep(3);
    if((lseek(fd,off,SEEK_SET))==-1) //move the file pointer to the 'off' length behind the start of file ,thus, a file will full with 'off' bits '\0'
        perror("lseek");

    if((write(fd,"largfile",8))==-1) // write 'largefile' 8 bits to the end of file
        perror("cannot write data");
}
